Convert to JS#22
Open
gitgrimbo wants to merge 8 commits intosgentle:masterfrom
Open
Conversation
This commit contains two variations of conversion. The most appropriate one should be used in a refactored PR. decaffeinate: https://github.com/decaffeinate/decaffeinate - pros - retains comments - uses es6 - let and const - template strings - lists recommendations for further conversion improvements - uses one declaration per line (personal preference) - cons - compact object literals on one line (personal preference) - e.g. current = {version, support, usage: 0}; - ifs on one line (personal preference) - e.g. if (nums == null) { nums = {}; } js2coffee: https://github.com/js2coffee/js2coffee - pros - TODO - cons - TODO
js-beautify -r --indent-size 2 INPUT-FILE
bin.js now requires caniuse-cli.js, and not the coffee-script files. The new caniuse-cli.js file is a CLI-only file that requires caniuser.decaffeinate.js caniuse.decaffeinate.js now provides two main functions: - toStreams() which will output to either default stdout and stderr, or two streams of your choice. - asString() which will return the output as a string. This separation will make it simple for other JS code to use the module to extract the output and use it in other situations, e.g. converting to HTML.
3aa6ad4 to
83c91f1
Compare
So we can use the args parser (and more importantly, the default
argument values it provides) in other code, e.g.:
```js
const caniuse = require("caniuse-cmd");
const args = process.argv.slice(2);
console.log(caniuse.asString(args));
```
2b5719e to
7ca27df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References #18.
I would say this PR is indicative at the moment and will require some rework, which I'm happy to do.
E.g. I have included two variations of automatic conversion from coffee-script to JS, using:
I have also left most of the indentation alone in order to simplify diffs. The finished code would require proper formatting.
The PR builds on the decaffeinate conversion as I preferred its output.